/*
 * Copyright (C) 2016. Tripint Information Technology Co., Ltd. All rights reserved. *
 * Authors:lirichen
 * File:ApiException.java
 * This software, including documentation, is protected by copyright controlled
 * by Tripint Information Technology Co., Ltd. All rights are reserved.
 */

package com.taorenqi.data.common;

/**
 *
 */
public class ApiException extends RuntimeException {

    public static final int ERROR_CODE = 0;

    public ApiException(int resultCode,String msg) {
        this(getApiExceptionMessage(resultCode,msg));
    }

    public ApiException(String detailMessage) {
        super(detailMessage);
    }

    /**
     * 由于服务器传递过来的错误信息直接给用户看的话，用户未必能够理解
     * 需要根据错误码对错误信息进行一个转换，在显示给用户
     * @param code
     * @return
     */
    private static String getApiExceptionMessage(int code,String msg){
        String message = "";
        switch (code) {
            case ERROR_CODE://0
                message = msg;
                break;
            default:
                message = "未知错误";
                break;
        }
        return message;
    }
}

